package com.example.teatea.dao;

import com.example.teatea.project.Staff;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;

public class GetMenuNum {
    public int getMenuNum(){
        int result = 0;
        Connection conn = null;
        ResultSet res = null;
        try {
//            boolean f = false;
            Properties info=new Properties();
            info.load(new FileInputStream("src\\main\\resources\\com\\example\\teatea\\sql.properties"));
            String user=info.getProperty("user");
            String password=info.getProperty("password");
            String Driver=info.getProperty("Driver");
            String url=info.getProperty("url");
            //注册驱动
            Class.forName(Driver);
            //获取连接
            conn = DriverManager.getConnection(url, user, password);
            String sql = "select mId from menu";
            PreparedStatement presta = conn.prepareStatement(sql);
            res = presta.executeQuery();
            while (res.next()) {
                result = res.getInt("mId");
//                System.out.println(result);
//                return result;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
